<?php


namespace App\Models\GameDB\Castle;

use Illuminate\Database\Eloquent\Model;

class CastleDrawLog extends Model
{
    protected $connection = 'mysql_game';
    /**
     * The table associated with the model.
     *
     * @var string
     */
    protected $table = 'ln_game_castle_draw_log';
    protected $fillable = [];
    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $guarded = [];

    /**
     * @param string $uid
     * @return \Illuminate\Database\Eloquent\Builder[]|\Illuminate\Database\Eloquent\Collection|\Illuminate\Database\Query\Builder[]|\Illuminate\Support\Collection
     * 获取记录
     */
    public function Log($perPage=10)
    {
        $query = CastleDrawLog::query()
            ->leftJoin('ln_game_castle_gift as gift', 'ln_game_castle_draw_log.draw_item_id', '=', 'gift.id');
        return $query->orderByDesc('ln_game_castle_draw_log.id')
             ->select([
                 'gift.id as gift_id','gift.name','gift.picture','ln_game_castle_draw_log.id as draw_id'
             ])->where('ln_game_castle_draw_log.is_draw',1)->limit($perPage)->get();

    }
}
